/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
/*
 * ---------------------------------------------------------------
 * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API        ##
 * ##                                                           ##
 * ## AUTHOR: acacode                                           ##
 * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
 * ---------------------------------------------------------------
 */

export interface Car {
  /** 车辆ID */
  _id?: string;
  /** 用户ID */
  userId?: string;
  /** 车辆昵称 */
  name: string;
  /** 车辆类型 */
  category: "小汽车" | "电车" | "摩托车" | "卡车" | "其他";
  /** 品牌 */
  brand: string;
  /** 型号 */
  carModel: string;
  /** 生产时间（时间戳） */
  productionTime: number;
  /** 购买时间（时间戳） */
  purchaseTime: number;
  /** 车类型（燃油车、电车、摩托车） */
  vehicleType: "fuel" | "electric" | "motor";
  /** 车牌号 */
  licensePlate?: string;
  /** 备注 */
  notes?: string;
  /** 当前里程 */
  currentMileage?: number;
  /** 油箱容积 */
  fuelCapacity?: number;
  /** 燃油类型 */
  fuelType?: "#92" | "#95" | "#98" | "柴油" | "电" | "其他";
  /** 购买价格 */
  purchasePrice?: number;
  /** 货币 */
  currency?: "CNY" | "USD" | "EUR";
  /** 电池容量 */
  batteryCapacity?: number;
  /** 续航里程 */
  mileage?: number;
  /**
   * 创建时间
   * @format date-time
   */
  createdAt?: string;
  /**
   * 更新时间
   * @format date-time
   */
  updatedAt?: string;
}

export interface CreateCarRequest {
  /** 车辆昵称 */
  name: string;
  /** 车辆类型 */
  category: "小汽车" | "电车" | "摩托车" | "卡车" | "其他";
  /** 品牌 */
  brand: string;
  /** 型号 */
  carModel: string;
  /** 生产时间（时间戳） */
  productionTime: number;
  /** 购买时间（时间戳） */
  purchaseTime: number;
  /** 车类型（燃油车、电车、摩托车） */
  vehicleType: "fuel" | "electric" | "motor";
  /** 车牌号 */
  licensePlate?: string;
  /** 备注 */
  notes?: string;
  /** 当前里程 */
  currentMileage?: number;
  /** 油箱容积 */
  fuelCapacity?: number;
  /** 燃油类型 */
  fuelType?: "#92" | "#95" | "#98" | "柴油" | "电" | "其他";
  /** 购买价格 */
  purchasePrice?: number;
  /** 货币 */
  currency?: "CNY" | "USD" | "EUR";
  /** 电池容量 */
  batteryCapacity?: number;
  /** 续航里程 */
  mileage?: number;
}

export interface UpdateCarRequest {
  /** 车辆昵称 */
  name?: string;
  /** 品牌 */
  brand?: string;
  /** 型号 */
  carModel?: string;
  /** 车牌号 */
  licensePlate?: string;
  /** 备注 */
  notes?: string;
  /** 当前里程 */
  currentMileage?: number;
  /** 油箱容积 */
  fuelCapacity?: number;
  /** 燃油类型 */
  fuelType?: "#92" | "#95" | "#98" | "柴油" | "电" | "其他";
  /** 购买价格 */
  purchasePrice?: number;
  /** 货币 */
  currency?: "CNY" | "USD" | "EUR";
  /** 车类型（燃油车、电车、摩托车） */
  vehicleType?: "fuel" | "electric" | "motor";
  /** 电池容量 */
  batteryCapacity?: number;
  /** 续航里程 */
  mileage?: number;
}

export interface PaginationInfo {
  /**
   * 当前页码
   * @example 1
   */
  page?: number;
  /**
   * 每页数量
   * @example 10
   */
  limit?: number;
  /**
   * 总数量
   * @example 25
   */
  total?: number;
  /**
   * 总页数
   * @example 3
   */
  totalPages?: number;
}

export interface CarListData {
  /** 车辆列表 */
  cars?: Car[];
  pagination?: PaginationInfo;
}

export interface SuccessResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "操作成功"
   */
  message?: string;
}

export interface CarSuccessResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "操作成功"
   */
  message?: string;
  data?: Car;
}

export interface CarListResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取车辆列表成功"
   */
  message?: string;
  data?: CarListData;
}

export interface ErrorResponse {
  /**
   * 操作是否成功
   * @example false
   */
  success?: boolean;
  /**
   * 错误消息
   * @example "请求参数错误"
   */
  message?: string;
}

export interface RegisterRequest {
  /** 用户名 */
  username: string;
  /**
   * 邮箱
   * @format email
   */
  email: string;
  /** 密码 */
  password: string;
}

export interface LoginRequest {
  /**
   * 邮箱
   * @format email
   */
  email: string;
  /** 密码 */
  password: string;
}

export interface AuthResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "登录成功"
   */
  message?: string;
  data?: {
    /** JWT令牌 */
    token?: string;
    user?: User;
  };
}

export interface User {
  /** 用户ID */
  _id?: string;
  /** 用户名 */
  username?: string;
  /** 邮箱 */
  email?: string;
  /**
   * 创建时间
   * @format date-time
   */
  createdAt?: string;
  /**
   * 更新时间
   * @format date-time
   */
  updatedAt?: string;
}

export interface UserProfileResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取用户信息成功"
   */
  message?: string;
  data?: User;
}

export interface UpdateProfileRequest {
  /** 用户名 */
  username?: string;
  /**
   * 邮箱
   * @format email
   */
  email?: string;
}

export interface SetDefaultVehicleRequest {
  /** 车辆ID */
  vehicleId: string;
}

export interface SetDefaultVehicleResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "默认车辆设置成功"
   */
  message?: string;
  data?: {
    /** 默认车辆ID */
    defaultVehicleId?: string;
    vehicle?: {
      /** 车辆ID */
      id?: string;
      /** 车辆昵称 */
      name?: string;
      /** 品牌 */
      brand?: string;
      /** 型号 */
      carModel?: string;
      /** 车牌号 */
      licensePlate?: string;
    };
  };
}

export interface GetDefaultVehicleResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取默认车辆成功"
   */
  message?: string;
  data?: {
    /** 默认车辆ID */
    defaultVehicleId?: string | null;
    /** 未设置默认车辆 */
    vehicle?: Car | null;
  };
}

export interface Expense {
  /** 费用ID */
  _id?: string;
  /** 用户ID */
  userId?: string;
  /** 车辆ID */
  vehicleId: string;
  /** 费用类型 */
  type: string;
  /** 费用金额 */
  amount: number;
  /** 货币 */
  currency?: "CNY" | "USD" | "EUR";
  /**
   * 费用日期
   * @format date
   */
  date: string;
  /** 费用描述 */
  description?: string;
  /** 费用地点 */
  location?: string;
  /** 里程数 */
  mileage?: number;
  /**
   * 创建时间
   * @format date-time
   */
  createdAt?: string;
  /**
   * 更新时间
   * @format date-time
   */
  updatedAt?: string;
}

export interface CreateExpenseRequest {
  /** 车辆ID */
  vehicleId: string;
  /** 费用类型 */
  type: string;
  /** 里程数 */
  mileage: number;
  fuelInfo?: {
    /** 表显单价 */
    showPrice: number;
    /** 实付单价 */
    actualPrice?: number;
    /** 表显金额 */
    showAmount: number;
    /** 加油量 */
    fuelAmount: number;
    /** 燃油类型 */
    fuelType?: "#92" | "#95" | "#98" | "柴油" | "电" | "其他";
    /** 优惠金额 */
    discountAmount?: number;
    /** 实付金额 */
    actualAmount?: number;
  };
  /**
   * 邮箱是否加满
   * @default false
   */
  isFull?: boolean;
  /**
   * 上次是否记录
   * @default false
   */
  isRecord?: boolean;
  /**
   * 油箱灯是否亮
   * @default false
   */
  isWarning?: boolean;
  /**
   * 货币
   * @default "CNY"
   */
  currency?: "CNY" | "USD" | "EUR";
  /**
   * 费用日期
   * @format date
   */
  date: string;
  /** 备注 */
  notes?: string;
  /** 费用地点 */
  location?: string;
  /** 里程表（保留向后兼容） */
  odometer?: number;
  /** 描述（保留向后兼容） */
  description?: string;
  /** 图片URL */
  imageUrl?: string;
}

export interface UpdateExpenseRequest {
  /** 费用类型 */
  type?: string;
  /** 费用金额 */
  amount?: number;
  /** 货币 */
  currency?: "CNY" | "USD" | "EUR";
  /**
   * 费用日期
   * @format date
   */
  date?: string;
  /** 费用描述 */
  description?: string;
  /** 费用地点 */
  location?: string;
  /** 里程数 */
  mileage?: number;
}

export interface ExpenseSuccessResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "操作成功"
   */
  message?: string;
  data?: Expense;
}

export interface ExpenseListData {
  /** 费用列表 */
  expenses?: Expense[];
  pagination?: PaginationInfo;
}

export interface ExpenseListResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取费用列表成功"
   */
  message?: string;
  data?: ExpenseListData;
}

export interface Income {
  /** 收入ID */
  _id?: string;
  /** 用户ID */
  userId?: string;
  /** 车辆ID */
  vehicleId: string;
  /** 收入类型 */
  type: string;
  /** 收入金额 */
  amount: number;
  /** 货币 */
  currency?: "CNY" | "USD" | "EUR";
  /**
   * 收入日期
   * @format date
   */
  date: string;
  /** 收入描述 */
  description?: string;
  /**
   * 创建时间
   * @format date-time
   */
  createdAt?: string;
  /**
   * 更新时间
   * @format date-time
   */
  updatedAt?: string;
}

export interface CreateIncomeRequest {
  /** 车辆ID */
  vehicleId: string;
  /** 收入类型 */
  type: string;
  /** 收入金额 */
  amount: number;
  /**
   * 货币
   * @default "CNY"
   */
  currency?: "CNY" | "USD" | "EUR";
  /**
   * 收入日期
   * @format date
   */
  date: string;
  /** 收入描述 */
  description?: string;
}

export interface UpdateIncomeRequest {
  /** 收入类型 */
  type?: string;
  /** 收入金额 */
  amount?: number;
  /** 货币 */
  currency?: "CNY" | "USD" | "EUR";
  /**
   * 收入日期
   * @format date
   */
  date?: string;
  /** 收入描述 */
  description?: string;
}

export interface IncomeSuccessResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "操作成功"
   */
  message?: string;
  data?: Income;
}

export interface IncomeListData {
  /** 收入列表 */
  incomes?: Income[];
  pagination?: PaginationInfo;
}

export interface IncomeListResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取收入列表成功"
   */
  message?: string;
  data?: IncomeListData;
}

export interface ExpenseType {
  /** 费用类型ID */
  _id?: string;
  /** 费用类型名称 */
  name: string;
  /** 费用类型代码 */
  code: string;
  /** 费用类型描述 */
  description?: string;
  /**
   * 创建时间
   * @format date-time
   */
  createdAt?: string;
  /**
   * 更新时间
   * @format date-time
   */
  updatedAt?: string;
}

export interface CreateExpenseTypeRequest {
  /** 费用类型名称 */
  name: string;
  /** 费用类型代码 */
  code: string;
  /** 费用类型描述 */
  description?: string;
}

export interface UpdateExpenseTypeRequest {
  /** 费用类型名称 */
  name?: string;
  /** 费用类型描述 */
  description?: string;
}

export interface ExpenseTypeSuccessResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "操作成功"
   */
  message?: string;
  data?: ExpenseType;
}

export interface ExpenseTypeListData {
  /** 费用类型列表 */
  expenseTypes?: ExpenseType[];
}

export interface ExpenseTypeListResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取费用类型列表成功"
   */
  message?: string;
  data?: ExpenseTypeListData;
}

export interface UserDataExportResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "导出成功"
   */
  message?: string;
  data?: {
    /** 用户信息 */
    user?: object;
    /** 车辆列表 */
    vehicles?: any[];
    /** 费用列表 */
    expenses?: any[];
    /** 收入列表 */
    incomes?: any[];
    /** 燃油记录列表 */
    fuelRecords?: any[];
    /** 保养记录列表 */
    maintenanceRecords?: any[];
    /** 维修记录列表 */
    repairRecords?: any[];
    /** 充电记录列表 */
    chargingRecords?: any[];
    /**
     * 导出时间
     * @format date-time
     */
    exportDate?: string;
    /** 记录总数统计 */
    totalRecords?: object;
  };
}

export interface DateRangeExportResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "导出成功"
   */
  message?: string;
  data?: {
    /**
     * 开始日期
     * @format date
     */
    startDate?: string;
    /**
     * 结束日期
     * @format date
     */
    endDate?: string;
    /** 数据类型 */
    dataType?: string;
    /** 导出的记录 */
    records?: any[];
    /** 数据摘要 */
    summary?: object;
    /**
     * 导出时间
     * @format date-time
     */
    exportDate?: string;
  };
}

export interface ExpenseReportExportResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "导出成功"
   */
  message?: string;
  data?: {
    period?: {
      /** 开始日期 */
      startDate?: string;
      /** 结束日期 */
      endDate?: string;
    };
    /** 费用记录总数 */
    totalExpenses?: number;
    /** 总费用金额 */
    totalAmount?: number;
    /** 费用统计 */
    expenseStats?: object;
    /** 车辆统计 */
    vehicleStats?: object;
    /** 费用列表 */
    expenses?: any[];
    /**
     * 导出时间
     * @format date-time
     */
    exportDate?: string;
  };
}

export interface BackupResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "备份创建成功"
   */
  message?: string;
  data?: {
    backup?: {
      /** 备份版本 */
      version?: string;
      /**
       * 备份时间
       * @format date-time
       */
      backupDate?: string;
      /** 用户信息 */
      user?: object;
      /** 备份数据 */
      data?: object;
      /** 数据摘要 */
      summary?: object;
    };
    /** 下载链接 */
    downloadUrl?: string;
  };
}

export interface FuelTrendChartResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 时间标签 */
    labels?: string[];
    /** 数据集 */
    datasets?: {
      /** 数据集标签 */
      label?: string;
      /** 数据值 */
      data?: number[];
    }[];
    /** 统计摘要 */
    summary?: object;
  };
}

export interface ExpenseTrendChartResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 时间标签 */
    labels?: string[];
    /** 数据集 */
    datasets?: {
      /** 数据集标签 */
      label?: string;
      /** 数据值 */
      data?: number[];
    }[];
    /** 统计摘要 */
    summary?: object;
  };
}

export interface IncomeTrendChartResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 时间标签 */
    labels?: string[];
    /** 数据集 */
    datasets?: {
      /** 数据集标签 */
      label?: string;
      /** 数据值 */
      data?: number[];
    }[];
    /** 统计摘要 */
    summary?: object;
  };
}

export interface ExpensePieChartResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 费用类型标签 */
    labels?: string[];
    /** 数据集 */
    datasets?: {
      /** 数据值 */
      data?: number[];
      /** 背景颜色 */
      backgroundColor?: string[];
    }[];
    /** 统计摘要 */
    summary?: object;
  };
}

export interface MileageTrendChartResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 时间标签 */
    labels?: string[];
    /** 数据集 */
    datasets?: {
      /** 数据集标签 */
      label?: string;
      /** 数据值 */
      data?: number[];
    }[];
    /** 统计摘要 */
    summary?: object;
  };
}

export interface ExpenseStatisticsResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 总费用金额 */
    totalAmount?: number;
    /** 费用记录总数 */
    totalCount?: number;
    /** 平均费用金额 */
    averageAmount?: number;
    /** 按类型统计 */
    byType?: object;
    /** 按车辆统计 */
    byVehicle?: object;
    /** 按月统计 */
    byMonth?: object;
    period?: {
      /**
       * 开始日期
       * @format date
       */
      startDate?: string;
      /**
       * 结束日期
       * @format date
       */
      endDate?: string;
    };
  };
}

export interface IncomeStatisticsResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 总收入金额 */
    totalAmount?: number;
    /** 收入记录总数 */
    totalCount?: number;
    /** 平均收入金额 */
    averageAmount?: number;
    /** 按类型统计 */
    byType?: object;
    /** 按车辆统计 */
    byVehicle?: object;
    /** 按月统计 */
    byMonth?: object;
    period?: {
      /**
       * 开始日期
       * @format date
       */
      startDate?: string;
      /**
       * 结束日期
       * @format date
       */
      endDate?: string;
    };
  };
}

export interface FuelStatisticsResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 总燃油费用 */
    totalFuelAmount?: number;
    /** 总燃油量 */
    totalFuelVolume?: number;
    /** 平均油耗 */
    averageFuelConsumption?: number;
    /** 总里程 */
    totalMileage?: number;
    /** 燃油效率 */
    fuelEfficiency?: number;
    /** 按车辆统计 */
    byVehicle?: object;
    /** 按月统计 */
    byMonth?: object;
    period?: {
      /**
       * 开始日期
       * @format date
       */
      startDate?: string;
      /**
       * 结束日期
       * @format date
       */
      endDate?: string;
    };
  };
}

export interface ExpenseRatioStatisticsResponse {
  /**
   * 操作是否成功
   * @example true
   */
  success?: boolean;
  /**
   * 响应消息
   * @example "获取成功"
   */
  message?: string;
  data?: {
    /** 总费用 */
    totalExpenses?: number;
    /** 费用比例列表 */
    expenseRatios?: {
      /** 费用类型 */
      type?: string;
      /** 费用金额 */
      amount?: number;
      /** 占比百分比 */
      percentage?: number;
    }[];
    /** 按车辆的费用比例 */
    byVehicle?: object;
    period?: {
      /**
       * 开始日期
       * @format date
       */
      startDate?: string;
      /**
       * 结束日期
       * @format date
       */
      endDate?: string;
    };
  };
}

import type {
  AxiosInstance,
  AxiosRequestConfig,
  HeadersDefaults,
  ResponseType,
} from "axios";
import axios from "axios";

export type QueryParamsType = Record<string | number, any>;

export interface FullRequestParams
  extends Omit<AxiosRequestConfig, "data" | "params" | "url" | "responseType"> {
  /** set parameter to `true` for call `securityWorker` for this request */
  secure?: boolean;
  /** request path */
  path: string;
  /** content type of request body */
  type?: ContentType;
  /** query params */
  query?: QueryParamsType;
  /** format of response (i.e. response.json() -> format: "json") */
  format?: ResponseType;
  /** request body */
  body?: unknown;
}

export type RequestParams = Omit<
  FullRequestParams,
  "body" | "method" | "query" | "path"
>;

export interface ApiConfig<SecurityDataType = unknown>
  extends Omit<AxiosRequestConfig, "data" | "cancelToken"> {
  securityWorker?: (
    securityData: SecurityDataType | null,
  ) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
  secure?: boolean;
  format?: ResponseType;
}

export enum ContentType {
  Json = "application/json",
  JsonApi = "application/vnd.api+json",
  FormData = "multipart/form-data",
  UrlEncoded = "application/x-www-form-urlencoded",
  Text = "text/plain",
}

export class HttpClient<SecurityDataType = unknown> {
  public instance: AxiosInstance;
  private securityData: SecurityDataType | null = null;
  private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
  private secure?: boolean;
  private format?: ResponseType;

  constructor({
    securityWorker,
    secure,
    format,
    ...axiosConfig
  }: ApiConfig<SecurityDataType> = {}) {
    this.instance = axios.create({
      ...axiosConfig,
      baseURL: axiosConfig.baseURL || "http://localhost:5001",
    });
    this.secure = secure;
    this.format = format;
    this.securityWorker = securityWorker;
  }

  public setSecurityData = (data: SecurityDataType | null) => {
    this.securityData = data;
  };

  protected mergeRequestParams(
    params1: AxiosRequestConfig,
    params2?: AxiosRequestConfig,
  ): AxiosRequestConfig {
    const method = params1.method || (params2 && params2.method);

    return {
      ...this.instance.defaults,
      ...params1,
      ...(params2 || {}),
      headers: {
        ...((method &&
          this.instance.defaults.headers[
            method.toLowerCase() as keyof HeadersDefaults
          ]) ||
          {}),
        ...(params1.headers || {}),
        ...((params2 && params2.headers) || {}),
      },
    };
  }

  protected stringifyFormItem(formItem: unknown) {
    if (typeof formItem === "object" && formItem !== null) {
      return JSON.stringify(formItem);
    } else {
      return `${formItem}`;
    }
  }

  protected createFormData(input: Record<string, unknown>): FormData {
    if (input instanceof FormData) {
      return input;
    }
    return Object.keys(input || {}).reduce((formData, key) => {
      const property = input[key];
      const propertyContent: any[] =
        property instanceof Array ? property : [property];

      for (const formItem of propertyContent) {
        const isFileType = formItem instanceof Blob || formItem instanceof File;
        formData.append(
          key,
          isFileType ? formItem : this.stringifyFormItem(formItem),
        );
      }

      return formData;
    }, new FormData());
  }

  public request = async <T = any, _E = any>({
    secure,
    path,
    type,
    query,
    format,
    body,
    ...params
  }: FullRequestParams): Promise<T> => {
    const secureParams =
      ((typeof secure === "boolean" ? secure : this.secure) &&
        this.securityWorker &&
        (await this.securityWorker(this.securityData))) ||
      {};
    const requestParams = this.mergeRequestParams(params, secureParams);
    const responseFormat = format || this.format || undefined;

    if (
      type === ContentType.FormData &&
      body &&
      body !== null &&
      typeof body === "object"
    ) {
      body = this.createFormData(body as Record<string, unknown>);
    }

    if (
      type === ContentType.Text &&
      body &&
      body !== null &&
      typeof body !== "string"
    ) {
      body = JSON.stringify(body);
    }

    return this.instance
      .request({
        ...requestParams,
        headers: {
          ...(requestParams.headers || {}),
          ...(type ? { "Content-Type": type } : {}),
        },
        params: query,
        responseType: responseFormat,
        data: body,
        url: path,
      })
      .then((response) => response.data);
  };
}

/**
 * @title AutoCost API
 * @version 1.0.0
 * @baseUrl http://localhost:5001
 * @contact AutoCost Team <support@autocost.com>
 *
 * AutoCost - 汽车费用管理应用后端API
 */
export class Api<
  SecurityDataType extends unknown,
> extends HttpClient<SecurityDataType> {
  api = {
    /**
     * No description
     *
     * @tags 车辆
     * @name CarsCreate
     * @summary 车辆录入
     * @request POST:/api/cars
     * @secure
     */
    carsCreate: (data: CreateCarRequest, params: RequestParams = {}) =>
      this.request<CarSuccessResponse, ErrorResponse>({
        path: `/api/cars`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 车辆
     * @name CarsList
     * @summary 获取车辆列表
     * @request GET:/api/cars
     * @secure
     */
    carsList: (
      query?: {
        /**
         * 页码
         * @default 1
         */
        page?: number;
        /**
         * 每页数量
         * @default 10
         */
        limit?: number;
        /** 车辆类型筛选 */
        category?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<CarListResponse, any>({
        path: `/api/cars`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 车辆
     * @name CarsDetail
     * @summary 获取车辆详情
     * @request GET:/api/cars/{id}
     * @secure
     */
    carsDetail: (id: string, params: RequestParams = {}) =>
      this.request<CarSuccessResponse, ErrorResponse>({
        path: `/api/cars/${id}`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 车辆
     * @name CarsUpdate
     * @summary 更新车辆信息
     * @request PUT:/api/cars/{id}
     * @secure
     */
    carsUpdate: (
      id: string,
      data: UpdateCarRequest,
      params: RequestParams = {},
    ) =>
      this.request<CarSuccessResponse, ErrorResponse>({
        path: `/api/cars/${id}`,
        method: "PUT",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 车辆
     * @name CarsDelete
     * @summary 删除车辆
     * @request DELETE:/api/cars/{id}
     * @secure
     */
    carsDelete: (id: string, params: RequestParams = {}) =>
      this.request<SuccessResponse, ErrorResponse>({
        path: `/api/cars/${id}`,
        method: "DELETE",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 认证
     * @name AuthRegisterCreate
     * @summary 用户注册
     * @request POST:/api/auth/register
     * @secure
     */
    authRegisterCreate: (data: RegisterRequest, params: RequestParams = {}) =>
      this.request<AuthResponse, ErrorResponse>({
        path: `/api/auth/register`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 认证
     * @name AuthLoginCreate
     * @summary 用户登录
     * @request POST:/api/auth/login
     * @secure
     */
    authLoginCreate: (data: LoginRequest, params: RequestParams = {}) =>
      this.request<AuthResponse, ErrorResponse>({
        path: `/api/auth/login`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 认证
     * @name AuthProfileList
     * @summary 获取用户信息
     * @request GET:/api/auth/profile
     * @secure
     */
    authProfileList: (params: RequestParams = {}) =>
      this.request<UserProfileResponse, any>({
        path: `/api/auth/profile`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 认证
     * @name AuthProfileUpdate
     * @summary 更新用户信息
     * @request PUT:/api/auth/profile
     * @secure
     */
    authProfileUpdate: (
      data: UpdateProfileRequest,
      params: RequestParams = {},
    ) =>
      this.request<UserProfileResponse, any>({
        path: `/api/auth/profile`,
        method: "PUT",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 认证
     * @name AuthSetDefaultVehicleUpdate
     * @summary 设置默认车辆
     * @request PUT:/api/auth/set-default-vehicle
     * @secure
     */
    authSetDefaultVehicleUpdate: (
      data: SetDefaultVehicleRequest,
      params: RequestParams = {},
    ) =>
      this.request<SetDefaultVehicleResponse, ErrorResponse>({
        path: `/api/auth/set-default-vehicle`,
        method: "PUT",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 认证
     * @name AuthGetDefaultVehicleList
     * @summary 获取默认车辆
     * @request GET:/api/auth/get-default-vehicle
     * @secure
     */
    authGetDefaultVehicleList: (params: RequestParams = {}) =>
      this.request<GetDefaultVehicleResponse, any>({
        path: `/api/auth/get-default-vehicle`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 费用
     * @name ExpensesCreate
     * @summary 创建费用记录
     * @request POST:/api/expenses
     * @secure
     */
    expensesCreate: (data: CreateExpenseRequest, params: RequestParams = {}) =>
      this.request<ExpenseSuccessResponse, any>({
        path: `/api/expenses`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 费用
     * @name ExpensesList
     * @summary 获取费用列表
     * @request GET:/api/expenses
     * @secure
     */
    expensesList: (
      query?: {
        /**
         * 页码
         * @default 1
         */
        page?: number;
        /**
         * 每页数量
         * @default 10
         */
        limit?: number;
        /** 车辆ID */
        vehicleId?: string;
        /** 费用类型 */
        type?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<ExpenseListResponse, any>({
        path: `/api/expenses`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 费用
     * @name ExpensesDetail
     * @summary 获取费用详情
     * @request GET:/api/expenses/{id}
     * @secure
     */
    expensesDetail: (id: string, params: RequestParams = {}) =>
      this.request<ExpenseSuccessResponse, any>({
        path: `/api/expenses/${id}`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 费用
     * @name ExpensesUpdate
     * @summary 更新费用记录
     * @request PUT:/api/expenses/{id}
     * @secure
     */
    expensesUpdate: (
      id: string,
      data: UpdateExpenseRequest,
      params: RequestParams = {},
    ) =>
      this.request<ExpenseSuccessResponse, any>({
        path: `/api/expenses/${id}`,
        method: "PUT",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 费用
     * @name ExpensesDelete
     * @summary 删除费用记录
     * @request DELETE:/api/expenses/{id}
     * @secure
     */
    expensesDelete: (id: string, params: RequestParams = {}) =>
      this.request<SuccessResponse, any>({
        path: `/api/expenses/${id}`,
        method: "DELETE",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 收入
     * @name IncomesCreate
     * @summary 创建收入记录
     * @request POST:/api/incomes
     * @secure
     */
    incomesCreate: (data: CreateIncomeRequest, params: RequestParams = {}) =>
      this.request<IncomeSuccessResponse, any>({
        path: `/api/incomes`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 收入
     * @name IncomesList
     * @summary 获取收入列表
     * @request GET:/api/incomes
     * @secure
     */
    incomesList: (
      query?: {
        /**
         * 页码
         * @default 1
         */
        page?: number;
        /**
         * 每页数量
         * @default 10
         */
        limit?: number;
        /** 车辆ID */
        vehicleId?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<IncomeListResponse, any>({
        path: `/api/incomes`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 收入
     * @name IncomesDetail
     * @summary 获取收入详情
     * @request GET:/api/incomes/{id}
     * @secure
     */
    incomesDetail: (id: string, params: RequestParams = {}) =>
      this.request<IncomeSuccessResponse, any>({
        path: `/api/incomes/${id}`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 收入
     * @name IncomesUpdate
     * @summary 更新收入记录
     * @request PUT:/api/incomes/{id}
     * @secure
     */
    incomesUpdate: (
      id: string,
      data: UpdateIncomeRequest,
      params: RequestParams = {},
    ) =>
      this.request<IncomeSuccessResponse, any>({
        path: `/api/incomes/${id}`,
        method: "PUT",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 收入
     * @name IncomesDelete
     * @summary 删除收入记录
     * @request DELETE:/api/incomes/{id}
     * @secure
     */
    incomesDelete: (id: string, params: RequestParams = {}) =>
      this.request<SuccessResponse, any>({
        path: `/api/incomes/${id}`,
        method: "DELETE",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 系统配置
     * @name ConfigExpenseTypesList
     * @summary 获取费用类型列表
     * @request GET:/api/config/expense-types
     * @secure
     */
    configExpenseTypesList: (params: RequestParams = {}) =>
      this.request<ExpenseTypeListResponse, any>({
        path: `/api/config/expense-types`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 系统配置
     * @name ConfigExpenseTypesCreate
     * @summary 新增费用类型
     * @request POST:/api/config/expense-types
     * @secure
     */
    configExpenseTypesCreate: (
      data: CreateExpenseTypeRequest,
      params: RequestParams = {},
    ) =>
      this.request<ExpenseTypeSuccessResponse, any>({
        path: `/api/config/expense-types`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 系统配置
     * @name ConfigExpenseTypesUpdate
     * @summary 修改费用类型
     * @request PUT:/api/config/expense-types/{id}
     * @secure
     */
    configExpenseTypesUpdate: (
      id: string,
      data: UpdateExpenseTypeRequest,
      params: RequestParams = {},
    ) =>
      this.request<ExpenseTypeSuccessResponse, any>({
        path: `/api/config/expense-types/${id}`,
        method: "PUT",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 系统配置
     * @name ConfigExpenseTypesDelete
     * @summary 删除费用类型
     * @request DELETE:/api/config/expense-types/{id}
     * @secure
     */
    configExpenseTypesDelete: (id: string, params: RequestParams = {}) =>
      this.request<SuccessResponse, any>({
        path: `/api/config/expense-types/${id}`,
        method: "DELETE",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 数据导出
     * @name ExportUserDataList
     * @summary 导出用户所有数据
     * @request GET:/api/export/user-data
     * @secure
     */
    exportUserDataList: (
      query?: {
        /**
         * 导出格式
         * @example "json"
         */
        format?: "json" | "csv";
      },
      params: RequestParams = {},
    ) =>
      this.request<UserDataExportResponse, ErrorResponse>({
        path: `/api/export/user-data`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 数据导出
     * @name ExportDateRangeList
     * @summary 导出指定时间范围的数据
     * @request GET:/api/export/date-range
     * @secure
     */
    exportDateRangeList: (
      query: {
        /**
         * 开始日期
         * @format date
         * @example "2024-01-01"
         */
        startDate: string;
        /**
         * 结束日期
         * @format date
         * @example "2024-12-31"
         */
        endDate: string;
        /**
         * 数据类型
         * @example "all"
         */
        dataType?:
          | "all"
          | "expenses"
          | "incomes"
          | "fuel"
          | "maintenance"
          | "repair"
          | "charging";
        /**
         * 导出格式
         * @example "json"
         */
        format?: "json" | "csv";
      },
      params: RequestParams = {},
    ) =>
      this.request<DateRangeExportResponse, ErrorResponse>({
        path: `/api/export/date-range`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 数据导出
     * @name ExportExpenseReportList
     * @summary 导出费用统计报告
     * @request GET:/api/export/expense-report
     * @secure
     */
    exportExpenseReportList: (
      query?: {
        /**
         * 年份
         * @example 2024
         */
        year?: number;
        /**
         * 月份
         * @min 1
         * @max 12
         * @example 12
         */
        month?: number;
        /**
         * 导出格式
         * @example "json"
         */
        format?: "json" | "csv";
      },
      params: RequestParams = {},
    ) =>
      this.request<ExpenseReportExportResponse, any>({
        path: `/api/export/expense-report`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 数据导出
     * @name ExportBackupCreate
     * @summary 创建数据备份
     * @request POST:/api/export/backup
     * @secure
     */
    exportBackupCreate: (params: RequestParams = {}) =>
      this.request<BackupResponse, any>({
        path: `/api/export/backup`,
        method: "POST",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 图表
     * @name ChartsFuelTrendList
     * @summary 获取燃油趋势图表数据
     * @request GET:/api/charts/fuel-trend
     * @secure
     */
    chartsFuelTrendList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<FuelTrendChartResponse, any>({
        path: `/api/charts/fuel-trend`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 图表
     * @name ChartsExpenseTrendList
     * @summary 获取费用趋势图表数据
     * @request GET:/api/charts/expense-trend
     * @secure
     */
    chartsExpenseTrendList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<ExpenseTrendChartResponse, any>({
        path: `/api/charts/expense-trend`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 图表
     * @name ChartsIncomeTrendList
     * @summary 获取收入趋势图表数据
     * @request GET:/api/charts/income-trend
     * @secure
     */
    chartsIncomeTrendList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<IncomeTrendChartResponse, any>({
        path: `/api/charts/income-trend`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 图表
     * @name ChartsExpensePieList
     * @summary 获取费用饼图数据
     * @request GET:/api/charts/expense-pie
     * @secure
     */
    chartsExpensePieList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<ExpensePieChartResponse, any>({
        path: `/api/charts/expense-pie`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 图表
     * @name ChartsMileageTrendList
     * @summary 获取里程趋势图表数据
     * @request GET:/api/charts/mileage-trend
     * @secure
     */
    chartsMileageTrendList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<MileageTrendChartResponse, any>({
        path: `/api/charts/mileage-trend`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 统计
     * @name StatisticsExpenseList
     * @summary 获取费用统计
     * @request GET:/api/statistics/expense
     * @secure
     */
    statisticsExpenseList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<ExpenseStatisticsResponse, any>({
        path: `/api/statistics/expense`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 统计
     * @name StatisticsIncomeList
     * @summary 获取收入统计
     * @request GET:/api/statistics/income
     * @secure
     */
    statisticsIncomeList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<IncomeStatisticsResponse, any>({
        path: `/api/statistics/income`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 统计
     * @name StatisticsFuelList
     * @summary 获取燃油统计
     * @request GET:/api/statistics/fuel
     * @secure
     */
    statisticsFuelList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<FuelStatisticsResponse, any>({
        path: `/api/statistics/fuel`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags 统计
     * @name StatisticsExpenseRatioList
     * @summary 获取费用比例统计
     * @request GET:/api/statistics/expense-ratio
     * @secure
     */
    statisticsExpenseRatioList: (
      query?: {
        /** 车辆ID */
        vehicleId?: string;
        /**
         * 统计周期
         * @example "month"
         */
        period?: "week" | "month" | "year";
      },
      params: RequestParams = {},
    ) =>
      this.request<ExpenseRatioStatisticsResponse, any>({
        path: `/api/statistics/expense-ratio`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),
  };
}
